<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Create New Member</title>
</head>
<body>
<script type="text/javascript">
	function textCounter( field, countfield, maxlimit ) {
	  if ( field.value.length > maxlimit )
	  {
	    field.value = field.value.substring( 0, maxlimit );
	    alert( 'Address value can only be 255 characters in length.' );
	   }
	  else
	  {
	    countfield.value = maxlimit - field.value.length;
	  }
	}
</script>
<%@ include file="header.jsp" %>
<form id="newAccountForm" name="createAccountForm" method="POST" action="CreateAccountServlet">
<% 
	String fName = (String)request.getAttribute("firstName");
	if(fName == null)
	{
		fName ="";
	}
	String lName = (String)request.getAttribute("lastName");
	if(lName == null)
	{
		lName ="";
	}
	String eMail = (String)request.getAttribute("email");
	if(eMail == null)
	{
		eMail ="";
	}
	String zip_Code = (String)request.getAttribute("zip");
	if(zip_Code == null)
	{
		zip_Code ="";
	}
	String city_value = (String)request.getAttribute("city");
	if(city_value == null)
	{
		city_value ="";
	}
	String state_value = (String)request.getAttribute("state");
	if(state_value == null)
	{
		state_value ="AL";
	}
	String address1 = (String)request.getAttribute("address1");
	if(address1 == null)
	{
		address1 ="";
	}
	String address2 = (String)request.getAttribute("address2");
	if(address2 == null)
	{
		address2 ="";
	}
	
	String customerType = (String) request.getAttribute("MembershipType");
	if(customerType == null)
	{
		customerType ="P";
	}
%>
<div class="inputColumn" id="createAccount"
	style="text-align: center; border: thin; margin: auto;" align="center">
<table cellpadding="2" cellspacing="1" border="0" width="100%"  align="center">
	<tr>
	<th colspan="2">
	<h3>New User? <small>Start here to Register:</small></h3>
	<font size="2" color="red"><sup>*</sup> Required Fields</font></th>
	</tr>
	<tr>
	<td colspan="2">
	<% String serverException = (String)request.getAttribute("ServerException");
					if(serverException != null){
				%><br> <label style="size: 32; color: red"><%=serverException%></label> <%} %>
	</td>
	</tr>
	<tr>
	<td>
		<table  cellpadding="2" cellspacing="1" border="1" width="65%" style="background-color: rgb(254,252,180);"  align="center">
			<tr>
			<th colspan="2">
			<h3>Personal Information</h3>
			</th>
			</tr>
			<tr>
			<td valign="top" align="left">
			<b>First Name<sup style="color: red">*</sup></b> <br>
			<input id="firstName" type="text" name="firstName" value = "<%=fName%>" size="35" maxlength="20" style="background-color:#eeeeee;"> 
				<% String firstName = (String)request.getAttribute("firstnameException");
					if(firstName != null){
				%><br> <label style="size: 32; color: red"><%=firstName%></label> <%} %>
			 </td>
			<td valign="top" align="left">
			<b>Last Name<sup style="color: red">*</sup></b> <br>
			<input type="text" name="lastName" id="lastName" value = "<%=lName%>" size="35" maxlength="20" style="background-color:#eeeeee;">
			<% String lastName = (String)request.getAttribute("lastnameException");
					if(lastName != null){
				%><br> <label style="size: 32; color: red"><%=lastName%></label> <%} %>
			</td>
			</tr>
			<tr>
				<td valign="top" align="left">
				<b>Address Line 1<sup style="color: red">*</sup></b> <br>
				<textarea id="address1" name="address1" rows="4" cols="30" onkeypress="textCounter(this,this.form.counter1,255);" style="background-color:#eeeeee;"><%=address1%></textarea>
				<% String address1exp = (String)request.getAttribute("addressException");
						if(address1exp != null)
						{
							%>
							 <br><label style="size: 32; color: red"><%=address1exp%></label> 
					   <%} %>
					   <br>
					<input type="text" name="counter1" maxlength="3" size="3" value="255" readonly="readonly"
				onblur="textCounter(this.form.counter1,this,255);" disabled="disabled"> chars remaining
				</td>
				<td valign="top" align="left">
				<b>Address Line 2</b> <br>
				<textarea id="address2" name="address2" rows="4" cols="30" onkeypress="textCounter(this,this.form.counter2,255);" style="background-color:#eeeeee;"><%=address2%></textarea>
					<% String address2exp = (String)request.getAttribute("addressException");
						if(address2exp != null){
					%><br> <label style="size: 32; color: red"><%=address2exp%></label> <%} %>
					<br>
					<input type="text" name="counter2" maxlength="3" size="3" value="255" readonly="readonly"
				onblur="textCounter(this.form.counter2,this,255);" disabled="disabled"> chars remaining
				</td>
			</tr>
			<tr>
				<td valign="top" align="left">
				<b>City<sup style="color: red">*</sup></b> <br>
				<input type="text" name="city" value = "<%=city_value%>"
					size="35" maxlength="125" style="background-color:#eeeeee;">
				<% String city = (String)request.getAttribute("cityException");
						if(city != null)
						{
							%>
							<br> <label style="size: 32; color: red"><%=city%></label> 
					   <%} %>
				</td>
				<td valign="top" align="left">
				<b>State<sup style="color: red">*</sup></b> <br> &nbsp;
				<select id= "state" name="state" style="background-color:#eeeeee;"> 
				<option value="AL"> Alabama      </option>	
				<option value="AK"> Alaska        </option>
				<option value="AS"> American Samoa         </option>
				<option value="AZ"> Arizona        </option>
				<option value="AR"> Arkansas         </option>
				<option value="CA"> California        </option>
				<option value="CO"> Colorado        </option>
				<option value="CT"> Connecticut        </option>
				<option value="DE"> Delaware         </option>
				<option value="DC"> District of Columbia        </option>
				<option value="FM"> Federated States of Micronesia        </option>
				<option value="FL"> Florida        </option>
				<option value="GA"> Georgia        </option>
				<option value="GU"> Guam         </option>
				<option value="HI"> Hawaii         </option>
				<option value="ID"> Idaho         </option>
				<option value="IL"> Illinois         </option>
				<option value="IN"> Indiana         </option>
				<option value="IA"> Iowa         </option>
				<option value="KS"> Kansas         </option>
				<option value="KY"> Kentucky         </option>
				<option value="LA"> Louisiana         </option>
				<option value="ME"> Maine         </option>
				<option value="MH"> Marshall Islands        </option>
				<option value="MD"> Maryland        </option>
				<option value="MA"> Massachusetts        </option>
				<option value="MI"> Michigan         </option>
				<option value="MN"> Minnesota         </option>
				<option value="MS"> Mississippi         </option>
				<option value="MO"> Missouri         </option>
				<option value="MT"> Montana        </option>
				<option value="NE"> Nebraska         </option>
				<option value="NV"> Nevada         </option>
				<option value="NH"> New Hampshire        </option>
				<option value="NJ"> New Jersey         </option>
				<option value="NM"> New Mexico        </option>
				<option value="NY"> New York        </option>
				<option value="NC"> North Carolina        </option>
				<option value="ND"> North Dakota         </option>
				<option value="MP"> Northern Mariana Islands         </option>
				<option value="OH"> Ohio         </option>
				<option value="OK"> Oklahoma         </option>
				<option value="OR"> Oregon         </option>
				<option value="PW"> Palau        </option>
				<option value="PA"> Pennsylvania         </option>
				<option value="PR"> Puerto Rico        </option>
				<option value="RI"> Rhode Island         </option>
				<option value="SC"> South Carolina         </option>
				<option value="SD"> South Dakota         </option>
				<option value="TN"> Tennessee         </option>
				<option value="TX"> Texas         </option>
				<option value="UT"> Utah         </option>
				<option value="VT"> Vermont        </option>
				<option value="VI"> Virgin Island         </option>
				<option value="VA"> Virginia         </option>
				<option value="WA"> Washington         </option>
				<option value="WV"> West Virginia        </option>
				<option value="WI"> Wisconsin         </option>
				<option value="WY"> Wyoming        </option>
				</select>
				<script>   
				document.getElementById("state").options.value = '<%= state_value%>';   
				</script>
				</td>
			</tr>
			<tr>
			  <td valign="top" align="left">
				<b>ZipCode<sup style="color: red">*</sup></b> <br>
				<input type="text" name="zip" id="zip" value = "<%=zip_Code%>"
					size="35" maxlength="125" style="background-color:#eeeeee;">
				<% String zip = (String)request.getAttribute("zipException");
						if(zip != null)
						{
							%>
							<br> <label style="size: 32; color: red"><%=zip%></label> 
					   <%} %>
				</td>
				<td/>
		</tr>
		</table>	
	</td>
	</tr>
	<tr>
	<td>
	<table cellpadding="2" cellspacing="1" border="1" width="65%" style="background-color: rgb(254,252,180);"  align="center">
			<tr>
			<th colspan="2">
			<h3>Membership Information</h3>
			</th>
			</tr>
			<tr>
			<td valign="top" align="left">
				<b>Membership Type<sup style="color: red">*</sup></b> <br> &nbsp;
				<select id= "categoryType" name="categoryType" style="background-color:#eeeeee;"> 
				<option value="P"> Premium Member      </option>	
				<option value="S"> Simple Member        </option>
				</select>
				<script>   
				document.getElementById("categoryType").options.value = '<%= customerType%>';   
				</script>
				</td>
			</tr>
			<tr>
			  <td valign="top" align="left">
				<b>E-Mail<sup style="color: red">*</sup></b> <br>
				<input type="text" name="email" id="email" value = "<%=eMail%>"
					size="35" maxlength="125" style="background-color:#eeeeee;">
				<% String email = (String)request.getAttribute("emailException");
						if(email != null)
						{
							%>
							<br> <label style="size: 32; color: red"><%=email%></label> 
					   <%} %>
				</td>
				<td valign="top" align="left">
				<b>Confirm Email<sup style="color: red">*</sup></b> <br>
				<input type="text" name="email2" id="email2" size="35"
					value="" maxlength="125" style="background-color:#eeeeee;"> 
					<% String confirmemail = (String)request.getAttribute("confirmemailException");
						if(confirmemail != null){
					%> <br><label style="size: 32; color: red"><%=confirmemail%></label> <%} %>
				</td>
			</tr>
			<tr>
				<td valign="top" align="left">
				<b>Password<sup style="color: red">*</sup></b> <br>
				<input type="password" id="password1" name="password1" size="35"
					value="" maxlength="30" style="background-color:#eeeeee;">
					 <br><label style="size: 9;">alpha-numeric value with minimun of 8 characters</label>
					<% String password = (String)request.getAttribute("passwordException");
						if(password != null){
					%> <br><label style="size: 32; color: red"><%=password%></label> <%} %>
				</td>
				<td valign="top" align="left">
				<b>Confirm Password<sup style="color: red">*</sup></b> <br>
				<input type="password" name="password2" id="password2" size="35"
					value="" maxlength="30" style="background-color:#eeeeee;"> 
					<% String confirmPass = (String)request.getAttribute("confirmpassException");
						if(confirmPass != null){
					%><br> <label style="size: 32; color: red"><%=confirmPass%></label> <%} %>
				</td>
			</tr>
			</table>
	</td>
	</tr>		
	<tr>
		<td align="center" colspan="2"><input type="submit"
			value="Register"> <input type="button" value="Cancel"
			onclick="document.location.href='welcome.jsp'"></td>
	</tr>
</table>
</div>
</form>
</body>
</html>